package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.bean.Zh_user;

import java.util.List;
import java.util.Map;

// BaseMapper是MyBatis-Plus提供的模板mapper，其中包含了基本的CRUD方法，泛型为操作的 实体类型
public interface ZHUserMapper extends BaseMapper<Zh_user> {

//    @Select("select * from zh_test1 where id=#{id}")
//    Zh_test queryTestData(@Param("id") String id);
//
//    @Select("select zg.name, res.userName , res.passWord , res.isAdmin , res.shopId , res.num from ( select zu.userName , zu.passWord , zu.isAdmin , zs.shopId , zs.num from zh_users zu left join zh_shops zs on zu.id = zs.userId ) res left join zh_goods zg on res.shopId = zg.goodsId where res.userName = #{userName}")
//    List<Map> queryUserGood(@Param("userName") String userName);

    @Insert("insert into zh_users(userName, passWord, createdAt, updatedAt) values(#{userInfo.userName}, #{userInfo.passWord}, #{userInfo.createdAt}, #{userInfo.updatedAt})")
    void insertUser(@Param("userInfo") Zh_user userInfo);

    @Select("select * from zh_users")
    List<Map> getAllUser();

    @Select("delete from zh_users where id=#{userId}")
    void deleteUser(String userId);
}
